<?php

namespace App\Models;

use App\Common\Traits\HasAgentRevenues;
use App\Common\Traits\HasPaymentOrders;

class AgentTopUpOrder extends Base
{
    use HasAgentRevenues, HasPaymentOrders;

    /**
     * 状态: 下单
     */
    const STATUS_PLACE = 1;

    /**
     * 状态: 完成
     */
    const STATUS_COMPLETE = 2;

    /**
     * 状态: 取消
     */
    const STATUS_CANCEL = 3;

    /**
     * 状态: 失败
     */
    const STATUS_FAIL = 4;

    /**
     * 支付状态
     */
    const STATUS_MAP = [
        self::STATUS_PLACE => '充值中',
        self::STATUS_COMPLETE => '充值成功',
        self::STATUS_CANCEL => '取消充值',
        self::STATUS_FAIL => '充值失败'
    ];

    protected $casts = [
        'created_at' => 'datetime:Y-m-d H:i:s',
        'updated_at' => 'datetime:Y-m-d H:i:s',
        'reward_setting_snapshot' => 'array',
    ];

    public function agent()
    {
        return $this->belongsTo(Agent::class, 'agent_id');
    }
}
